#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import socket


s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# 建立连接:
s.connect(('127.0.0.1', 9999))
# 接收欢迎消息:
print(s.recv(1024).decode('utf-8'))
while True:
    # 发送数据:
    name = input('please enter your name: ')
    s.send(name.encode('utf-8'))
    print(s.recv(1024).decode('utf-8'))
    if name == 'exit':
        s.close()
        break

